package cn.itcast.bos.web.action.take_delivery;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.domain.take_delivery.Order;
import cn.itcast.bos.domain.utils.BaseAction;
import cn.itcast.bos.service.take_delivery.OrderService;

@ParentPackage("json-default")
@Namespace("/")
@Scope("prototype")
@Controller
public class OrderAction extends BaseAction<Order> {
	
	@Autowired
	private OrderService orderService;
	
	
	 @Action(value="findByorderNum",results={@Result(name="success",type="json")})
	 public String findByorderNum(){
		 
		 Order order= orderService.findByorderNum(model.getOrderNum());
		 Map<String, Object> result= new HashMap<String,Object>();
		  if(order!=null){
			  //说明查询到了数据
			  result.put("success", true);
			  result.put("orderData", order);
		  }else{
			  result.put("success", false);
		  }
		 ServletActionContext.getContext().getValueStack().push(result);
		 return SUCCESS;
	 }
}
